#! /usr/bin/python
import person_pb2
from datetime import datetime
import time  

person = person_pb2.Person()
person.id = 1000
person.name = "Alice"
person.email = "Alice@example.com"
personMsg = person_pb2.Person()
"""
phone1 = person.Extensions[person_pb2.Phone.phones].add()
phone1.num = "2147483647"
phone1.type = person_pb2.Phone.HOME
phone2 = person.Extensions[person_pb2.Phone.phones].add()
phone2.num = "2147483647"
phone2.type = person_pb2.Phone.MOBILE
"""
start = datetime.now() 
personMsg
for i in range(10000):
    data = person.SerializeToString()
    personMsg.ParseFromString(data)
stop = datetime.now()
print(personMsg)
print 'cost_time: ', (stop - start).seconds*1000 + (stop - start).microseconds/1000,'ms'

